<?php

if (!defined('BASEPATH'))
  exit('No direct script access allowed');

class Article extends MY_Controller{
	
  public function __construct(){
	  
    parent::__construct();
    if ($this->is_logged_in() == FALSE){
		
      redirect('administrator');
    }
    else{
      $this->load->model('article_model');
      //$this->load->model('image_model');
	  $this->load->library('grocery_CRUD');
    }
  }
  
  /**
   * Displays list of albums for regular users. Admins can see all albums.
   */
 	 public function index(){
		
		//create the grocery crud object
		 $crud = new grocery_CRUD();	
		 
		//set  the table for grocery_crud
		$crud->set_table('article')
				->columns('name','body','published')
				->fields('name','body','published')
				->display_as('name','Article Name')
				->set_lang_string('list_record','Article')
				->set_lang_string('list_no_items','No articles to display');
	
		// $crud->unset_operations();
		 
		 //$crud->unset_edit();
		 
		//hide password filed in the grid
		 //$crud->unset_columns('uuid','id','created_by','updated_at','updated_by','created_at');
		 //$crud->unset_edit_fields('uuid','id','created_by','updated_at','updated_by','created_at');
		
		 //$crud->set_theme('datatables');
	
		//disable the edit functionality in the delete users grid
		//$this->grocery_crud->unset_edit();
	
		//if admin delete any user, callback event occurs (for update the system  log)
		//$this->grocery_crud->callback_after_delete(array($this,'user_after_delete'));
	
			
		$output = $crud->render();
		$this->load->view('article',$output);
	
		}
    
}
